/*	1->I
 *	2->J
 *	3->L
 *	4->O
 *	5->S  
 *	6->Z 
 *	7->T 
 */



import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.util.Timer;

public class rect extends JFrame
{
int x = 0;
int y = 0;
JPanel j;
private static final int INITIAL_DELAY = 1; // milliseconds
Pieces p = new Pieces(x,y,"t");
TimerTask t1;
Timer t2 = new Timer();

Dimension d = new Dimension(585,409);
public rect()
{
	
	t2 = new Timer();
	
	t1= new TimerTask(){   //Anonymous Inner class
	public void  run()
	{
		moveDown();	
		
	
		
	}
		
		
	};
	
	
	t2.schedule(t1,10,1000);
	
this.setSize(d.height,d.width);

this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

  

j = new JPanel()
	{

	public void paintComponent(Graphics G)
	{

		
        drawP(G);
       
        
	}

	};

j.setSize(d.height,d.width);

 this.add(j);




	
this.addKeyListener(
new KeyAdapter()
{
	
public void keyPressed(KeyEvent e)
{
	
keyPress(e);	
}	
}

);	



this.setVisible(true);


}

public void drawP(Graphics g)
{
p.drawPiece(g);	
	
}



public void moveRight()
{
	if(p.getfirstCorner()==400 || p.getsecondCorner() == 400 )
		{
	
		}
	else
		{
		x=x+50;
		p.setfirstCorner(x,x,y);
		
		
		this.repaint();
		}
}


public void moveLeft()
{
	if(p.getfirstCorner()==0 || p.getsecondCorner() == 0 )
		{
			
		}
	else
	{
	x=x-50;
	p.setfirstCorner(x,x,y);
	this.repaint();
	}

}

public void moveDown()
{
	
	if( p.getthirdCorner() == 500 )
	{
		
	}
    else
    {
	y=y+50;
	p.setfirstCorner(x,x,y);
	this.repaint();
	}
}

public void rotate()
{


this.repaint();

}
/*
public void drawT(Graphics G)
{

        G.drawRect(x,y,50,50);
        G.drawRect(x+50,y,50,50); 
        G.drawRect(x+100,y,50,50); 
        G.drawRect(x+50,y+50,50,50);

         
         



}
*/
/*
public void drawL(Graphics g)
{

  g.drawRect(x,y,50,50);
  g.drawRect(x,y+50,50,50);
  g.drawRect(x,y+100,50,50);
  //g.drawRect(x,y+150,50,50);
  g.drawRect(x+50,y+100,50,50);



}*/
/*
public void drawS(Graphics g)
{    
	g.drawRect(x+100,y,50,50);
	g.drawRect(x+50,y,50,50);
	g.drawRect(x+50,y+50,50,50);
	g.drawRect(x,y+50,50,50);
	
}	

*/

/*
public void drawZ(Graphics g)
{    
	
	g.drawRect(x,y,50,50);
	g.drawRect(x+50,y,50,50);
	g.drawRect(x+50,y+50,50,50);
	g.drawRect(x+100,y+50,50,50);
	
	
	
}*/

private  void keyPress(KeyEvent e) {
	int keyCode = e.getKeyCode();
	if(keyCode==e.VK_LEFT)    //checks that if user presses 1 then whether an action is performed or not
	{
	moveLeft();
	}

	if(keyCode==e.VK_RIGHT)    //checks that if user presses 1 then whether an action is performed or not
	{
	moveRight();
	}

	if(keyCode==e.VK_DOWN)    //checks that if user presses 1 then whether an action is performed or not
	{
	moveDown();
	}

	if(keyCode==e.VK_R)
	{

	rotate();
	}




	}






public static void main(String args[])
{

rect r = new rect();







}






}
